package com.flipdf2.serialize.ppml.element;

import org.jdom.Element;
import org.jdom.Namespace;

import com.flipdf2.serialize.ppml.PPMLException;

public class PPMLFont {
	public static final String NAME = "FONT";
	
	private String fontName;
	private String format;
	
	public Element toXML(Namespace defaultNamespace) {
		Element root = null;
		if (defaultNamespace != null) {
			root = new Element(NAME, defaultNamespace);
		} else {
			root = new Element(NAME);	
		}
		
		if (fontName != null) 
			root.setAttribute("FontName", fontName);
		if (format != null) 
			root.setAttribute("Format", format);
		
		return root;
	}
	
	public void check() throws PPMLException {
		if (fontName == null) {
			throw PPMLException.getInstance(PPMLException.REQUIRED_ATTRIBUTE_LOST, "FontName");
		}
		if (format == null) {
			throw PPMLException.getInstance(PPMLException.REQUIRED_ATTRIBUTE_LOST, "Format");
		}
	}

	public String getFontName() {
		return fontName;
	}

	public void setFontName(String fontName) {
		this.fontName = fontName;
	}

	public String getFormat() {
		return format;
	}

	public void setFormat(String format) {
		this.format = format;
	}
}
